import errorCode from "../../utils/http/errorCode";
import http from "@/utils/http/hub";

/**
 * 确认订单 传入参数 返回对应预订单信息
 */
export const orderConfirm = (
  params,
  config = {
    custom: {
      auth: true,
    },
  }
) => {
  return http.post({
    url: `/order/confirm`,
    params,
    config,
  });
};

/**
 * 立即购买
 */
export const orderImmediate = (
  params,
  config = {
    custom: {
      auth: true,
    },
  }
) => {
  return http.post({
    url: `/order/immediate`,
    params,
    config,
  });
};

/**
 * 获取订单列表
 */
export const getOrderList = (
  params,
  config = {
    custom: {
      auth: true,
    },
  }
) => {
  return http.get({
    url: `/order/getList`,
    params,
    config,
  });
};

/**
 * 取消订单
 */
export const cancelOrder = (
  params,
  config = {
    custom: {
      auth: true,
    },
  }
) => {
  return http.post({
    url: `/order/cancelOrder`,
    params,
    config,
  });
};

/**
 * 获取订单详情
 */
export const getOrderDetail = (
  params,
  config = {
    custom: {
      auth: true,
      debounce: false,
    },
  }
) => {
  return http.get({
    url: `/order/detail`,
    params,
    config,
  });
};

/**
 * 轮训获取订单详情
 */
export const matchingOrderDetail = (
  params,
  config = {
    custom: {
      auth: true,
    },
  }
) => {
  return http.get({
    url: `/order/matchingOrderDetail`,
    params,
    config,
  });
};

/**
 * 确认服务
 */
export const receiptOrder = (
  params,
  config = {
    custom: {
      auth: true,
    },
  }
) => {
  return http.post({
    url: `/order/receiptOrder`,
    params,
    config,
  });
};

/**
 * 申请售后
 */
export const refundOrder = (
  params,
  config = {
    custom: {
      auth: true,
    },
  }
) => {
  return http.post({
    url: `/order/refundOrder`,
    params,
    config,
  });
};

/**
 * 取消申请售后
 * orderServiceRefundId : 申请退款id
 */
export const cancelRefundOrder = (
  params,
  config = {
    custom: {
      auth: true,
    },
  }
) => {
  return http.post({
    url: `/order/cancelRefundOrder`,
    params,
    config,
  });
};

/**
 * 申请售后详情
 */
export const refundOrderDetail = (
  params,
  config = {
    custom: {
      auth: true,
    },
  }
) => {
  return http.post({
    url: `/order/refundOrderDetail`,
    params,
    config,
  });
};

/**
 * 0元支付
 */
export const freePay = (
  params,
  config = {
    custom: {
      auth: true,
    },
  }
) => {
  return http.post({
    url: `/order/freePay`,
    params,
    config,
  });
};

/**
 * 同意或拒绝二次上门
 * localNo
 * type 1同意2拒绝
 */
export const operationSecondService = (
  params,
  config = {
    custom: {
      auth: true,
    },
  }
) => {
  return http.post({
    url: `/order/operationSecondService`,
    params,
    config,
  });
};

/**
 * 加急详情
 */
export const urgentDetail = (
  params,
  config = {
    custom: {
      auth: true,
    },
  }
) => {
  return http.post({
    url: `/order/urgentDetail`,
    params,
    config,
  });
};

/**
 * 出发中保洁位置
 */
export const nowLocation = (
  params,
  config = {
    custom: {
      auth: true,
      loading: false,
    },
  }
) => {
  return http.post({
    url: `/order/nowLocation`,
    params,
    config,
  });
};

/**
 * 预约订单
 */
export const subscribeOrder = (
  params,
  config = {
    custom: {
      auth: true,
      loading: true,
    },
  }
) => {
  return http.post({
    url: `/order/subscribeOrder`,
    params,
    config,
  });
};

/**
 * 修改预约订单[抖音]
 */
export const updateSubscribeOrder = (
  params,
  config = {
    custom: {
      auth: true,
      loading: true,
    },
  }
) => {
  return http.post({
    url: `/order/updateSubscribeOrder`,
    params,
    config,
  });
};

// /**
//  * 退款前取消预约订单[抖音]
//  */
// export const cancelSubscribeOrder = (
//   params,
//   config = {
//     custom: {
//       auth: true,
//       loading: true,
//     },
//   }
// ) => {
//   return http.post({
//     url: `/order/cancelSubscribeOrder`,
//     params,
//     config,
//   });
// };

/**
 * 退款前取消预约订单[抖音]
 */
export const cancelSubscribeOrder = (
  params,
  config = {
    custom: {
      auth: true,
      loading: true,
    },
  }
) => {
  return new Promise((resolve) => {
    resolve({
      code: errorCode.success,
      msg: "取消成功",
    });
  });
};
